import {fileURLToPath, URL} from 'node:url'

import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
  plugins: [
      vue()
  ],
   server: {
     port: 8989,
     host: '0.0.0.0',
     open: true,// 自动打开浏览器
     cors: true,// 解决跨域问题
     proxy: {
       '/tp': {
         target: 'http://localhost:9090',
         changeOrigin: true,
         rewrite: (path) => path.replace(/^\/tp/, ''),
       },
       '/MP': {
         target: 'http://cos.tuxiw.cn',
         changeOrigin: true,
         rewrite: (path) => path.replace(/^\/MP/, ''),
       },
     },
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
